package externalflame.systemdesign.secondkill.exception;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class UniformExceptionAdvice {

    @ExceptionHandler(NoStockException.class)
    public String handleNoStockException() {
        return "库存告急";
    }

    @ExceptionHandler(NoSuchSecKillException.class)
    public String handleNoSuchSecKillException() {
        return "没找见你说的秒杀活动";
    }

    @ExceptionHandler(NotValidPeriodException.class)
    public String handleNotValidPeriodException() {
        return "秒杀活动还未开始";
    }

    @ExceptionHandler(PerPurchaseLimitException.class)
    public String handlePerPurchaseLimitException() {
        return "商品限购，您无法继续购买";
    }
}
